import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-28
 * Time: 13:34
 */
class Solution {
    public int countSegments(String s) {
        if(s.equals("")) {
            return 0;
        }
        String[] s1 = s.split(" ");
        int count = 0;
        for (int i = 0; i < s1.length; i++) {
            if(s1[i] == "") {
                count++;
            }
        }
        return s1.length - count;
    }
}
class Solution1 {
    public String toLowerCase(String s) {
        StringBuilder stringBuilder = new StringBuilder();
        char[] array = s.toCharArray();
        for (int i = 0; i < array.length; i++) {
            if(array[i] >= 'A' && array[i] <= 'Z') {
                stringBuilder.append((char)(array[i] + 32));
            }else {
                stringBuilder.append(array[i]);
            }
        }
        return stringBuilder.toString();
    }
}
public class Test {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.countSegments(", , , ,        a, eaefa"));
    }
    public static void main1(String[] args) {
        Solution1 solution = new Solution1();
        String str = "shdSDgs";
        System.out.println(solution.toLowerCase(str));
    }
}
